package api

import (
	"myproject/backend/types"
	"myproject/backend/utils"
)

// 查询训练计划详情
func (c *GoodsApi) TrainDetail(req types.TrainPlanDetailReq) types.TrainPlanDetailResp2 {
	resp := types.TrainPlanDetailResp2{}
	body := map[string]interface{}{
		"listId": req.ListId,
	}
	err := utils.HttpRequest(utils.HttpRequestOptions{
		Method: "POST",
		Suffix: "/train/train/plan/detail",
		Resp:   &resp,
		Body:   body,
	})

	if err != nil {
		resp.Code = types.FAIL
		resp.Msg = err.Error()
		return resp
	}
	return resp
}

// 创建训练计划
func (c *GoodsApi) CreateTrainPlan(req types.TrainPlanCreateReq) types.JsResp {
	resp := types.JsResp{}
	body := map[string]interface{}{
		"listId": req.ListId,
		"age":    req.Age,
	}
	err := utils.HttpRequest(utils.HttpRequestOptions{
		Method: "GET",
		Suffix: "/train/train/plan/create",
		Resp:   &resp,
		Body:   body,
	})
	if err != nil {
		resp.Code = types.FAIL
		resp.Msg = err.Error()
		return resp
	}
	return resp
}
